'''
Created on Aug 6, 2013

@author: Yuanpeng_Li
1.4 Write a method to decide if two strings are anagrams or not.
'''

def are_anagrams(str1, str2):
    buffer = [0] * 256
    for c in str1:
        a = ord(c)
        buffer[a] += 1
    
    for c in str2:
        buffer[ord(c)] -= 1
        
    for i in buffer:
        if i != 0:
            return False
    return True

if __name__ == '__main__':
    str1 = "abc"
    str2 = "cba"
    print(are_anagrams(str1, str2))